package name.jiaosha.air.iostorage.controller;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import name.jiaosha.air.AppConstants;
import name.jiaosha.air.iostorage.domain.Inventory;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ali8ba.Domain;

@Controller
@RequestMapping("/admin/inventory")
public class InventoryController extends Domain {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3141397773244935123L;

	@RequestMapping("/findList")
	public ModelAndView findRecord() {

		List<Inventory> list = null;
		int total = 0;

		if (AppConstants.DEBUG) {
			list = new ArrayList<Inventory>();
			for (int i = 0; i < 20; i++) {
				Inventory inventory = new Inventory();
				inventory.setId(i);
				inventory.setName("底盘部件W240L.1" + i);
				inventory.setProductCode("201245240359" + i);
				inventory.setCost(new BigDecimal(9.08+i));
				inventory.setAmount(new BigDecimal(10 + i));
				inventory.setUnit("台");
				inventory.setStorageId(i);
				list.add(inventory);
			}
			total = list.size();

		} else {

		}

		ModelMap model = new ModelMap();
		model.addAttribute("root", list);
		model.addAttribute("totalProperty", total);
		return new ModelAndView("jsonView", model);
	}

}
